package com.wxq.ware.dao;

import com.wxq.ware.entity.WareSkuEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 商品库存
 * 
 * @author jim
 * @email 2982877319@qq.com
 * @date 2022-03-13 20:21:35
 */
@Mapper
public interface WareSkuDao extends BaseMapper<WareSkuEntity> {

    /**
     * 更新商品库存
     * @param skuId
     * @param wareId
     * @param skuNum
     */
    void updateStock(@Param("skuId") Long skuId,
                     @Param("wareId") Long wareId,
                     @Param("skuNum") Integer skuNum);

    /**
     * 查询当前库存量
     * @param skuId
     * @return
     */
    long getSkuStock(Long skuId);

    void unLockStock(Long skuId, Long wareId, Integer num);

    List<Long> listWareIdHasSkuStock(Long skuId);

    Long lockSkuStock(Long skuId, Long wareId, Integer num);
}
